using ASP;
using HoWave.Common;
using HoWave.Web;
using HoWave.Web.Shop;
using System;
using System.Data;
using System.Text;
using System.Web.Profile;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
public class UserControls_2012_ProductDetailTopUC : UserControl
{
	protected Literal ltrCurrentCity;
	protected HtmlAnchor A1;
	protected HtmlAnchor A2;
	protected Literal ltraLLHotCity;
	protected HiddenField HFSelectCity;
	protected TextBox txtProductName1;
	protected Button btnSearchService;
	protected TextBox txtShopName1;
	protected Button btnSearchShop;
	private string _name;
	private string _shopRootUrl = string.Empty;
	private string _currentCity = string.Empty;
	private string _selectType = string.Empty;
	private int _selectTypeID = 0;
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	public string User_Name
	{
		get
		{
			Shop shop = new Shop();
			if (shop.user != null)
			{
				this._name = shop.user.UserName;
			}
			return this._name;
		}
		set
		{
			this._name = value;
		}
	}
	public string ShopRootUrl
	{
		get
		{
			string shopRootUrl;
			if (!string.IsNullOrEmpty(this._shopRootUrl))
			{
				shopRootUrl = this._shopRootUrl;
			}
			else
			{
				SiteConfigBll siteConfigBll = new SiteConfigBll();
				DataTable siteConfig = siteConfigBll.GetSiteConfig();
				this._shopRootUrl = siteConfig.Rows[0]["ShopRootUrl"].ToString();
				shopRootUrl = this._shopRootUrl;
			}
			return shopRootUrl;
		}
		set
		{
			this._shopRootUrl = value;
		}
	}
	public string CurrentCity
	{
		get
		{
			return this._currentCity;
		}
		set
		{
			this._currentCity = value;
		}
	}
	public string SelectType
	{
		get
		{
			return this._selectType;
		}
		set
		{
			this._selectType = value;
		}
	}
	public int SelectTypeID
	{
		get
		{
			return this._selectTypeID;
		}
		set
		{
			this._selectTypeID = value;
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		this.GetCityDomain();
		if (!base.IsPostBack)
		{
		}
	}
	private void GetCityNameByDomain()
	{
		string text = base.Request.Url.AbsoluteUri.Replace("http://", "");
		string text2 = "";
		if (text.IndexOf("." + this.ShopRootUrl) > 0)
		{
			text2 = text.Substring(0, text.IndexOf("." + this.ShopRootUrl));
			if (text2 == "www")
			{
				this.HFSelectCity.Value = "";
				return;
			}
		}
		Conn conn = new Conn();
		if (text2 != "")
		{
			IDbDataParameter dbDataParameter = conn.CreateParameter("@DomainName", DbType.String, text2);
			DataTable dataTable = conn.GetDataTable("select * from dbo.CM_Domain where DomainName=@DomainName", new IDbDataParameter[]
			{
				dbDataParameter
			});
			if (dataTable != null && dataTable.Rows.Count > 0)
			{
				this.HFSelectCity.Value = dataTable.Rows[0]["DomainName"].ToString() + "|" + dataTable.Rows[0]["City"].ToString();
				this.ltrCurrentCity.Text = dataTable.Rows[0]["City"].ToString();
				this._currentCity = dataTable.Rows[0]["City"].ToString();
			}
		}
		else
		{
			this.HFSelectCity.Value = "";
		}
	}
	private void GetCityDomain()
	{
		HoWave_Root hoWave_Root = new HoWave_Root();
		DataTable dataTable = new Conn().GetDataTable("select DomainName,SortNumber,City,Disable \r\n                                                                          from CM_Domain  where Disable=1  order by SortNumber Desc");
		StringBuilder stringBuilder = new StringBuilder("");
		foreach (DataRow dataRow in dataTable.Rows)
		{
			stringBuilder.Append(string.Concat(new object[]
			{
				"<a  href='http://",
				dataRow["DomainName"],
				".",
				this.ShopRootUrl,
				"'>",
				dataRow["City"],
				"</a>"
			}));
		}
		this.ltraLLHotCity.Text = stringBuilder.ToString();
	}
	protected void btnSearchService_Click(object sender, EventArgs e)
	{
		if (this.txtProductName1.Text == "输入商品名称")
		{
			this.txtProductName1.Text = "";
		}
		base.Response.Redirect("~\\ProductList.aspx?productname=" + this.txtProductName1.Text.Trim());
	}
	protected void btnSearchShop_Click(object sender, EventArgs e)
	{
		if (this.txtShopName1.Text == "输入店铺名称")
		{
			this.txtShopName1.Text = "";
		}
		base.Response.Redirect("~\\Search_Shop.aspx?ShopName=" + this.txtShopName1.Text);
	}
}
